package OfferCode;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author Kechelle
 * @Date 2020/9/10 19:35
 * @Version 1.0
 */
public class Code3 {
    public static int findRepeatNumber(int[] nums){
        Set<Integer> set = new HashSet<>();
        int repeat = -1;
        for (int num:nums){
            if (!set.add(num)){
                repeat = num;
                break;
            }
        }
        return repeat;
    }

    public static void main(String[] args) {
        int[] nums = {2,3,1,0,2,5,3};
        System.out.println(Code3.findRepeatNumber(nums));
    }
}
